package Regex;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class RegexDemo2 {
    public static void main(String[] args) {
        String str="Java自从问世以来，就有了Java11版本，而最牛逼的也是Java17,卒后i我i差五i随可惜啊Java12," +
                "长嫂就擦宋朝Java1。";
        Pattern p = Pattern.compile("Java\\d{0,2}");

        Matcher m=p.matcher(str);

        while(m.find()){
            String s=m.group();
            System.out.println(s);
        }

    }

    private static void method1() {
        String str="Java自从问世以来，就有了Java11版本，而最牛逼的也是Java17,卒后i我i差五i随可惜啊Java12," +
                "长嫂就擦宋朝Java1。";

        //Pattern 表示正则表达式
        //Matcher 文本匹配器

        Pattern p = Pattern.compile("Java\\d{0,2}");

        Matcher m=p.matcher(str);

        boolean b=m.find();

        String s1=m.group();
        System.out.println(s1);

        b=m.find();
        String s2=m.group();
        System.out.println(s2);
    }


}
